<template>
    <div class="dealer maxwidth">
        <div style="" class="dealer-head">
            <Row class="btns">
                <Col class="channelClick">
                    <!-- 当前按钮是否展示0（新增，修改）表示展示、1表示不展示（查看页面），-->
                    <Button type="primary" @click="submit()" icon="ios-create-outline">提交</Button>
                    <Button type="primary" @click="back()" icon="ios-create-outline">返回</Button>
                </Col>
            </Row>
            <ul class="channel_text channel_title ">
                <li v-for="(item,index) in tabsType" :key="index" :class="{active:curTab===index}" @click="toggle(index)">
                    <p><img :src="item.imgSrc" alt=""></p>
                   <span>{{item.value}}</span>
                </li>
            </ul>
        </div>
        <div class="specific_field" style="padding-top: 150px;">
            <div v-show="curTab===0">
                <!--基本信息-->
                <basic-info ref="basicInfo" :channelType="channelType" :newCarRole="newCarRole" :oldCarRole="oldCarRole" :channelStatus="channelStatus" :channelStatusOldCar="channelStatusOldCar" ></basic-info>
                    <Spin fix v-if="spinShow">
                        <Icon type="ios-loading" size=60 class="demo-spin-icon-load"></Icon>
                        <div>请稍后...</div>
                    </Spin>
            </div>
            <div v-show="curTab===1">
                <!--收款账号信息-->
                <account-info ref="accountModify" :isNewCarRole="isNewCarRole" :isOldCarRole="isOldCarRole"></account-info>
            </div>
            <div v-show="curTab===2">
                <!--备案信息-->
                <record-info ref="recordInfo" :channelId="channelId"></record-info>
            </div>
            <div v-show="curTab===3">
                <!--系统用户信息-->
                <use-info ref="useInfo" :channelId="channelId"></use-info>
            </div>
            <div v-show="curTab===4">
                <!--附件-->
               <!-- <attachment-info ref="attachmentInfo"></attachment-info>-->
                <file-operation  :uploadParam="uploadParam" :isInt="true" :path="path" readOnly></file-operation>
            </div>
            <div v-show="curTab===5">
                <!--档案日志-->
                <archives-log ref="archivesLog"></archives-log>
            </div>
        </div>

    </div>
</template>
<script>

import "_p/afs-channel/assets/css/channelBase.css";
import BasicInfo from "./quota-info/quotaInfo.vue";
import AccountInfo from "../../dealer-apply/dealer-online/payment-account/accountModify.vue";
import RecordInfo from "../../dealer-apply/dealer-online/record-info/recordInfo.vue";
import UseInfo from "../../dealer-apply/dealer-online/use-info/useInfo.vue";
import AttachmentInfo from "../../dealer-apply/dealer-online/attachment-info/attachmentInfo.vue";
import ArchivesLog from "../../dealer-apply/dealer-online/archives-log/archivesLog.vue";
import FileOperation from "_p/basic/pages/image/upload-file/fileOperation.vue";

export default {
    name:"dealerMain",
    props: {

    },
    data(){
        return{

            //附件部分
            uploadParam: {
                busiNo: "",
                belongNo: "",
                busiType: "",
                busiData: {}
            },
            path:"channel",

            //默认隐藏父页面
            channelManage:true,
            channelId:"",
            /*默认从基本信息开始*/
            typeCode:0,
            curTab:0,
            operationType:0,
            //渠道归属
            channelType:"",
            //是否拥有新车权限
            isNewCarRole:"",
            //是否拥有二手车权限
            isOldCarRole:"",
            newCarRole:"",
            oldCarRole:"",
            loadingStaging:false,
            loadingSave:false,
            spinShow: false,
            channelStatus:"",
            channelStatusOldCar:"",
            tabsType:[
                {
                    value:"基本信息",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon1.png"),
                },
                {
                    value:"收款账号信息",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon2.png"),
                },
                {
                    value:"备案信息",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon3.png"),
                },
                {
                    value:"系统用户信息",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon3.png"),
                },
                {
                    value:"附件",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon3.png"),
                },
                {
                    value:"档案日志",
                    imgSrc:require("_p/afs-apply/assets/img/apply_icon3.png"),
                }
            ],
            remarkForm:{
                remark:"",
            },
            remarkFormValidate:{
                remark:[
                ]
            },
        }
    },
    components:{
        //注入子组件
        BasicInfo,
        AccountInfo,
        RecordInfo,
        UseInfo,
        AttachmentInfo,
        ArchivesLog,
        FileOperation,
    },
    created(){
    },
    methods:{
        init() {
            if(this.afs.getPageParams(this).operationType==0){
                //新增操作
                //设置页面是否禁用
                //传入页面渠道类型判断渠道归属赋值
                this.channelType=this.afs.getPageParams(this).channelType;
                //传入是否拥有新车账号权限
                this.isNewCarRole=this.afs.getPageParams(this).isNewCarRole;
                //传入是否有二手车账户权限
                this.isOldCarRole=this.afs.getPageParams(this).isOldCarRole;
                this.newCarRole=this.afs.getPageParams(this).isNewCarRole;
                this.oldCarRole=this.afs.getPageParams(this).isOldCarRole;
                this.basicInfoView(this.afs.getPageParams(this).infoView);
            }else if(this.afs.getPageParams(this).operationType==1){
                //表示修改或查看
                //传入是否拥有新车账号权限
                this.isNewCarRole=this.afs.getPageParams(this).isNewCarRole;
                //传入是否有二手车账户权限
                this.isOldCarRole=this.afs.getPageParams(this).isOldCarRole;
                this.newCarRole=this.afs.getPageParams(this).isNewCarRole;
                this.oldCarRole=this.afs.getPageParams(this).isOldCarRole;
                //传入页面渠道类型判断渠道归属赋值
                this.channelType=this.afs.getPageParams(this).channelType;
                //获取渠道基本信息
                this.channel(this.afs.getPageParams(this).channelId);
                //设置按钮是否展示
                this.bottonView(this.afs.getPageParams(this).bottonView);
                //传值到备案信息也看
                this.channelId =this.afs.getPageParams(this).channelId;
                this.channelStatus=this.afs.getPageParams(this).channelStatus;
                this.channelStatusOldCar=this.afs.getPageParams(this).channelStatusOldCar
            }else if(this.afs.getPageParams(this).operationType==2){
                //表示修改或查看
                //传入是否拥有新车账号权限
                this.isNewCarRole=this.afs.getPageParams(this).isNewCarRole;
                //传入是否有二手车账户权限
                this.isOldCarRole=this.afs.getPageParams(this).isOldCarRole;
                this.newCarRole=this.afs.getPageParams(this).isNewCarRole;
                this.oldCarRole=this.afs.getPageParams(this).isOldCarRole;
                //传入页面渠道类型判断渠道归属赋值
                this.channelType=this.afs.getPageParams(this).channelType;
                //设置页面是否禁用
                this.basicInfoView(this.afs.getPageParams(this).infoView);
                //获取渠道基本信息
                this.channel(this.afs.getPageParams(this).channelId);
                //设置按钮是否展示
                this.bottonView(this.afs.getPageParams(this).bottonView);
                //传值到备案信息也看
                this.channelId =this.afs.getPageParams(this).channelId;
                this.channelStatus=this.afs.getPageParams(this).channelStatus;
                this.channelStatusOldCar=this.afs.getPageParams(this).channelStatusOldCar
            }
        },
        channel(v){
            //渠道基本信息获取
            this.$refs.basicInfo.getChannelInfo(v);
            //收款账号信息获取
            this.$refs.accountModify.getAccountInfo(v);
            //新车授权区域
            this.$refs.basicInfo.getMainAreaListNew(v);
            //二手车授权区域
            this.$refs.basicInfo.getMainAreaListOld(v);
            //主营品牌
            this.$refs.basicInfo.getBaseTreeList(v);
            //新车授权车型
            this.$refs.basicInfo.checkAllNewCar(v);
            //二手车授权车型
            this.$refs.basicInfo.checkAllOldCar(v);
            //获取部门树
            this.$refs.useInfo.getDeptInfoTree(v);
            //备案信息获取
            this.$refs.recordInfo.getWitnessList(v);
            //档案日志信息获取
            this.$refs.archivesLog.getArchivesLogInfo(v);
            this.channelId =v;
            if(this.channelId){
                this.initGetFilterParams();
            }
        },
        basicInfoView(v){
            //新车或者二手车赋值
            this.$refs.basicInfo.addCarRole(this.newCarRole,this.oldCarRole);
            //主营品牌树初始化
            this.$refs.basicInfo.getBaseTreeList();
            //授权区域初始化
            this.$refs.basicInfo.getMainAreaList();
            //授权车型树初始化
            this.$refs.basicInfo.getCarsTreeList();
            //基础信息
            this.$refs.basicInfo.readOnlyInfo(v);
            //收款账号信息
            this.$refs.accountModify.readOnlyInfo(v);
        },
        toggle(index){
            this.curTab=index;
        },
        submit(){
            this.$refs.basicInfo.basicSubmit();
        },
        submitWorkflow(){
            this.$refs.basicInfo.basicSubmitWorkflow();
        },
        save(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.basicSave();
            }else if(this.curTab=="1"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSave();
            }
        },
        staging(){
            if(this.curTab=="0"){
                //基本信息
                this.$refs.basicInfo.stagingSave();
            }else if(this.curTab=="1"){
                //收款账号信息
                let channelId = this.channelId;
                if(channelId==""||channelId == undefined) {
                    this.$Message.error("请先保存基本信息");
                    return;
                }
                this.$refs.accountInfo.invoiceSave();
            }
        },
        blacklist(){
            //黑名单
            this.$refs.basicInfo.blackChannel();
        },
        back(){
            //关闭页面
            this.afs.closeTab(this);
        },
        setchannelId(v){
            //获取子组件基本信息页面保存的渠道id
            this.channelId=v;

        },
        //点击编辑查看按钮展示不通的按钮
        bottonView(flag){
            this.typeCode=flag;
        },
        initGetFilterParams() {
            this.uploadParam.busiNo = this.channelId;
            this.uploadParam.belongNo = this.channelId;
            this.uploadParam.busiData = {};
            this.uploadParam.busiType = "dealerOnline";
        },
    },
    mounted() {
        this.init();
    }
}

</script>

<style >
    @import "../../../assets/css/channelBase.css";

    .dealer.maxwidth {
        max-width: 1572px;
        /* max-width: 95%; */
        margin: auto;
    }
    .dealer.maxwidth .dealer-head {
        max-width: 1572px;
        /* max-width: calc(95% - 226px); */
    }
    .dealer .dealer-head {
        position:fixed;
        width:calc(100% - 235px);
        z-index: 999;
        box-shadow: 0px 0px 10px #ccc;
        top:90px;
    }
    .channel_title img{
        position: relative;
        width: 17px;
        margin-top: 4px;
        z-index: 3;
    }
    .dealer .btns{
        background-color: white;
        padding: 20px 0 0 0;
    }
    .dealer .btns button{
        margin-right: 50px;
    }

    .dealer .channelClick{
        padding-bottom: 16px;
        display: flex;
        flex-flow: row;
        justify-content: flex-end;
        align-items: center;
    }
    .dealer .ivu-spin-fix{
        background-color: hsla(0,0%,100%,.5)
    }

    .dealer .demo-spin-col{
        height: 100px;
        position: relative;
        border: 1px solid #eee;
    }
    .dealer .demo-spin-icon-load{
        animation: ani-demo-spin 1s linear infinite;
    }

</style>
